package com.ruoyi.common.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MapHumpUtils {

    /**
     * 下划线转驼峰式命名法 例如：user_name->userName
     */
    public static Map<String,Object> toCamelCase(Map<String,Object> map){
        Map<String,Object> resultMap = new HashMap<String,Object>();
        for (String key: map.keySet()) {
            resultMap.put(StringUtils.toCamelCase(key), map.get(key));
        }
        return resultMap;
    }
    /**
     * 下划线转驼峰式命名法 例如：user_name->userName
     */
    public static List<Map<String,Object>> toCamelCase(List<Map<String,Object>> list){

        List<Map<String,Object>> resultList = new ArrayList<>();

        for(int i = 0;i<list.size();i++){
            resultList.add(toCamelCase(list.get(i)));
        }

        return resultList;
    }
    /**
     * 驼峰转下划线转命名法 例如：userName->user_name
     */
    public static Map<String,Object> toUnderScoreCase(Map<String,Object> map){
        Map<String,Object> resultMap = new HashMap<String,Object>();
        for (String key: map.keySet()) {
            resultMap.put(StringUtils.toUnderScoreCase(key), map.get(key));
        }
        return resultMap;
    }


}
